﻿
using System;
using Test30.Core;

namespace Test30.Engine
{
    public class LightAction : ElementBallAction
    {
        public LightAction(Entity entity, INoun noun, int radius, Attack attack)
            : base(entity, entity.Position, radius, noun, attack)
        {
            if (!(entity is Hero)) throw new ArgumentException("Lame. Right now LightAction uses the Hero's cached visibility data, so can't be used by other entities.");
        }

        protected override void OnEffect(Vec pos, Direction direction, bool leadingEdge)
        {
            // do the element attack, but only on the leading edge so we don't see the trails
            if (leadingEdge)
            {
                base.OnEffect(pos, direction, true);
            }
        }

        protected override bool IsTileAllowed(Vec pos)
        {
            //### bob: hack. assumes the hero is the one performing the action
            // only light up visible tiles so that walls block the light
            return Dungeon.Tiles[pos].IsVisible;
        }
    }
}
